package com.jiangds.open.check.checker;

import com.jiangds.open.check.Checker;
import java.time.LocalDateTime;

/**
 * {@link LocalDateTimeChecker} 本地时间校验器
 *
 * @author jiangliang
 * @since 2021/1/7 11:29
 */
public class LocalDateTimeChecker extends AbstractChecker<Integer, LocalDateTime> {

    public LocalDateTimeChecker(LocalDateTime target) {
        super(target);
    }

    @Override
    public Checker<Integer, LocalDateTime> notEmpty() {
        return notNull();
    }

    @Override
    public Checker<Integer, LocalDateTime> range(Integer min, Integer max) {
        return localDateRangeProcessor(LocalDateTime::toLocalDate, min, max);
    }

    @Override
    public Checker<Integer, LocalDateTime> greater(LocalDateTime greaterThan) {
        return processor(t -> !t.isBefore(greaterThan));
    }

    @Override
    public Checker<Integer, LocalDateTime> less(LocalDateTime lessThan) {
        return processor(t -> !t.isAfter(lessThan));
    }

    @Override
    public Checker<Integer, LocalDateTime> in(LocalDateTime... args) {
        return inProcessor(LocalDateTime::isEqual, args);
    }
}
